﻿using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lamex.mIE.Calculate
{
    public class LGC_VAL_T03_WELDING
    {
        public static double LGC_VAL_T03_WELDING_VALUE(string DWG_NO, string PART_NO, string Feature_Name)
        {
            string errorMessage = DWG_NO + ";" + PART_NO + ";" + Feature_Name;
            try
            {
                double W = 0;
                double H = 0;
                DataTable dt = Lamex.Base.BaseBuildSql.GetDataTableBySql(" select * from IE_Part_SizeParmList where DWG_NO='" + DWG_NO + "' and PART_NO='" + PART_NO + "'");
                if (dt.Rows.Count == 0)
                {
                    //XtraMessageBox.Show("【尺寸参数表没有该部件号,此数据不能作为保存数据,请确保尺寸参数表存有该数据】");
                    Lamex.Common.IniFile ini = new Lamex.Common.IniFile(Application.StartupPath + "\\RecordLostWorkTime.ini");
                    string str = ini.IniReadValue("Configuration", "RecoredName");
                    str += @"\r\n" + errorMessage + "尺寸参数表没有该部件号";
                    return 0;
                }
                if (dt.Rows[0]["WIDTH"].ToString().Trim().Length> 0)
                    W = double.Parse(dt.Rows[0]["WIDTH"].ToString());
                else
                    W = 0;
                if (dt.Rows[0]["HEIGHT"].ToString().Trim().Length > 0)
                    H = double.Parse(dt.Rows[0]["HEIGHT"].ToString());
                else
                    H = 0;

                double result_Val = 0;
                switch (Feature_Name)
                {
                    case "A66":
                        result_Val = 23;
                        break;
                    case "其它":
                        if (W > 1200 || H > 1200)
                            result_Val = 20;
                        else
                            result_Val = 15;
                        break;
                }
                return result_Val;
            }
            catch(Exception ex)
            {
                XtraMessageBox.Show(ex.Message+":"+errorMessage);
                return 0;
            }
        }
    }
}
